package com.cmower.baeldung.arrays1;

import java.util.Arrays;

public class SearchDemo {
    public static void main(String[] args) {
int[] anArray = new int[] {5, 2, 1, 4, 8};
int index = Arrays.binarySearch(anArray, 4);
        System.out.println(index);

for (int i = 0; i < anArray.length; i++) {
    if (anArray[i] == 4) {
        System.out.println("找到了 " + i);
        break;
    }
}
    }
}
